using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


public interface ISiteSelected
{
}
/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (this is ISiteSelected && this.SiteId == null)
        {
            Server.Transfer("~/Sites.aspx");
        }
    }

    protected int? SiteId
    {
        get
        {
            if (Session["BasePage.SiteId"] is int)
            {
                return (int)Session["BasePage.SiteId"];
            }
            else
            {
                return null;
            }
        }
        set
        {
            if (value.HasValue)
            {
                Session["BasePage.SiteId"] = value.Value;
            }
            else
            {
                Session.Remove("BasePage.SiteId");
            }
        }
    }

    private Acms.Bll.Site _selectedSite;
    protected Acms.Bll.Site SelectedSite
    {
        get
        {
            if (_selectedSite == null && SiteId != null)
            {
                _selectedSite = Acms.Bll.Site.GetById(SiteId.Value);
            }
            return _selectedSite;
        }
    }
    

}
